<%--
  -	Date: 2012-03-27
  -
  - Copyright (C) 2012 Jawa Software. All rights reserved.
  - 
  - 服务器属性管理页面。
--%>
<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ page import="java.text.*"%>
<%@ page import="org.apache.commons.lang.StringUtils"%>
<%@ page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@ page import="org.apache.commons.lang.time.DateUtils"%>
<%@ page import="org.jawa.core.util.JawaGlobals"%>
<%@ page import="org.jawa.core.JawaServer"%>

<!DOCTYPE html>
<html lang="en">
	<head>
		<title>服务器属性</title>
		<meta name="navID" content="1000" />
		<meta name="pageID" content="1101" />
	</head>
	<body>
		<div class="container-fluid">
			<fieldset>
				<legend>
					服务器属性
				</legend>
				<table class="table table-striped table-bordered ">
					<tbody>
						<tr>
							<th>
								系统版本:
							</th>
							<td>
								<%=JawaServer.getInstance().getVersion().getVersionString()%>
							</td>
						</tr>
						<tr>
							<th>
								启动时间:
							</th>
							<td>
								<%=JawaGlobals.formatDateTime(JawaServer.getInstance()
					.getServerInfo().getLastStarted())%>
							</td>
						</tr>
						<tr>
							<th>
								工作目录:
							</th>
							<td>
								<%=JawaGlobals.getHomeDirectory()%>
							</td>
						</tr>
					</tbody>
				</table>
			</fieldset>
			<fieldset>
				<legend>
					工作环境
				</legend>
				<table class="table table-striped table-bordered">
					<tbody>
						<tr>
							<th>
								JVM 版本和供应商:
							</th>
							<td>
								<%
									String vmName = System.getProperty("java.vm.name");
									if (vmName == null) {
										vmName = "";
									} else {
										vmName = " -- " + vmName;
									}
								%>
								<%=System.getProperty("java.version")%>
								<%=System.getProperty("java.vendor")%><%=vmName%>

							</td>
						</tr>
						<tr>
							<th>
								应用服务器:
							</th>
							<td>
								<%=application.getServerInfo()%>
							</td>
						</tr>
						<tr>
							<th>
								主机名:
							</th>
							<td>

								<%
									String host = "";
									try {
										host = java.net.InetAddress.getLocalHost().getHostName();
									} catch (Exception ex) {
										//
									}
								%>
								<%=host%>
							</td>
						</tr>
						<tr>
							<th>
								OS／硬件:
							</th>
							<td>
								<%=System.getProperty("os.name")%>
								/
								<%=System.getProperty("os.arch")%>
							</td>
						</tr>
						<tr>
							<th>
								Java 内存:
							</th>
							<td>
								<%
									// The java runtime
									Runtime runtime = Runtime.getRuntime();

									double freeMemory = (double) runtime.freeMemory() / (1024 * 1024);
									double maxMemory = (double) runtime.maxMemory() / (1024 * 1024);
									double totalMemory = (double) runtime.totalMemory() / (1024 * 1024);
									double usedMemory = totalMemory - freeMemory;
									double percentFree = ((maxMemory - usedMemory) / maxMemory) * 100.0;
									double percentUsed = 100 - percentFree;
									int percent = 100 - (int) Math.round(percentFree);

									DecimalFormat mbFormat = new DecimalFormat("#0.00");
									DecimalFormat percentFormat = new DecimalFormat("#0.0");

									String cssClass = "";
									if (percent >= 90) {
										cssClass = " progress-danger";
									} else {
										cssClass = " progress-info";
									}
								%>
								<div class=" progress <%=cssClass%>"
									style="border: 1px solid #DDDDDD; padding: 1px">
									<div class="bar"
										style="width: <%=percentFormat.format(percentUsed)%>%;"><%=percentFormat.format(percentUsed)%>%
									</div>
								</div>
								<span> 使用 <%=mbFormat.format(usedMemory)%> MB 共 <%=mbFormat.format(maxMemory)%>
									MB (<%=percentFormat.format(percentUsed)%>%) </span>
							</td>
						</tr>
					</tbody>
				</table>
			</fieldset>
		</div>
	</body>
</html>